package services

import (
	"context"
	"fmt"
	"github.com/cloudwego/hertz/pkg/app"
	"log"
	"login/src/core/net"
)

// GuestLogin 处理游客登录
func GuestLogin(ctx context.Context, c *app.RequestContext, req *net.LoginReq) (interface{}, error) {
	// 游客登录不需要 token 或密码
	loginData, ok := req.Data.(map[string]interface{})
	if !ok {
		return nil, fmt.Errorf("invalid login data")
	}

	account := loginData["account"].(string)

	// 游客登录的处理逻辑
	log.Printf("Guest login - Account: %s", account)

	// 返回用户信息或其他相关数据
	user := map[string]interface{}{
		"id":       0,
		"username": account,
		"platform": "Guest",
	}
	return user, nil
}
